package com.admin.action;

import com.admin.service.MemberAdminService;
import com.data.bean.Account;
import com.data.util.JsonUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;

import javax.servlet.http.HttpServletRequest;
import java.util.List;
import java.util.Map;

/**
 * 会员管理相关的Action
 *
 * @author:HingLo
 * @create 2017-08-31 9:31
 **/
@Controller
@RequestMapping("memberAdminAction/admin/")
public class MemberAdminAction {
    @Autowired
    private MemberAdminService memberAdminService;

    @RequestMapping("memberAdmin")
    public String memberAdminAction(@RequestParam("types") Integer types, HttpServletRequest request) {
        if (types != null) {
            List<Account> list = memberAdminService.findMemberService(types);
            request.setAttribute("dataMap", list);
            System.out.println(list.size());
        }
        request.setAttribute("types", types);
        return "/WEB-INF/admin/member_list";
    }

    @RequestMapping("deleteMemberAdmin")
    @ResponseBody
    public Map<String, Object> deleteMemberAdminAction(@RequestParam("id") String id, HttpServletRequest request) {
        boolean bool = memberAdminService.deleteMemberService(id);
        return JsonUtils.returnMassageUtils(bool, bool ? "删除成功" : "删除失败");
    }


}
